
CREATE FUNCTION delete_reports(integer)  Returns text  AS $$
DECLARE
rec record;

BEGIN

select report_name as rep into rec from master_report where report_id = $1;

DELETE FROM report_customization where customization_id in (select
customization_id from sys_report_customization where report_id=$1);

DELETE FROM sys_report_filter where report_id=$1;

DELETE FROM master_column_mapping where report_id=$1;

DELETE FROM sys_report_customization where report_id=$1;

DELETE FROM master_report where report_id=$1;
Return rec.rep; 
END;
$$ LANGUAGE plpgsql;

--execute function
select * from delete_reports(enter report id);



